local huakai = fk.CreateSkill{
    name = "lingling__huakai",
}
Fk:loadTranslationTable{
    ["lingling__huakai"] = "花开",
    [":lingling__huakai"] = "回合结束时，你获得一张【影】。回合开始时，你可以将一张【影】当【韬光养晦】使用。",

    ["#lingling__huakai-invoke"] = "花开：你可以将一张【影】当【韬光养晦】使用",
}
local U = require "packages/lingling/util"

huakai:addEffect(fk.TurnEnd,{
    anim_type = "drawcard",
    can_trigger = function (self, event, target, player, data)
        return player == target and player:hasSkill(huakai.name)
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local card = U.getShade(room, 1)
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonJustMove, huakai.name, nil, true, player)
    end,
})

huakai:addEffect(fk.TurnStart,{
    can_trigger = function (self, event, target, player, data)
        return player == target and player:hasSkill(huakai.name)
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local use = room:askToUseVirtualCard(player, {
            name = "ling__hide_capacities",
            skill_name = huakai.name,
            prompt = "#lingling__huakai-invoke",
            cancelable = true,
            card_filter = {
                n = 1,
                pattern = "shade",
            },
            skip = true,
        })
        if use then
            event:setCostData(self, {extra_data = use})
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:useCard(event:getCostData(self).extra_data)
    end,
})

return huakai